import request from "@/api/index.js";
import axios from "axios";

export function get(url, params) {
    return new Promise((resolve, reject) => {
        axios.get(url, {
            params: params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}

export function post(url, params, headers, type = 0) {
    return new Promise((resolve, reject) => {
        let typeList = [
            {
                data:params,
            },
            {
                params:params
            }
        ]
        axios({
            url: url,
            method: "POST",
            ...typeList[type],
            headers: headers ? headers : {'Content-Type': 'application/json',}
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
